package Repository;



import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import model.Account;
import model.Lead;
import model.Raw;

public class MarketingRepository
{
  
	private static Map<Long, Lead> rawLeadMap = new HashMap<Long, Lead>();
	static{
		Lead lead = new Lead();		
		lead.setName("Mythri") ;
		lead.setLeadDate(new Date(2009, 5, 11));
		lead.setAddress("California");
		lead.setFax("555555151");
		lead.setCity("San Jose");
		lead.setCountry("USA");
		lead.setEmail("mythri@yahoo.com");
		lead.setPhoneNum(650555666);
		lead.setCurrentState(new Raw());
		lead.setAccount(new Account());
		lead.setSource("phone");
		lead.setZip("95121");
		lead.setProductInterest("Dell laptop");
		lead.setInterestedCustomer("Y");
		lead.setSmsObjId(1);
		rawLeadMap.put(new Long(1), lead);
		
		lead = new Lead();
		lead.setName("Sandhya") ;
		lead.setLeadDate(new Date(2009, 6, 8));
		lead.setAddress("California");
		lead.setFax("586555151");
		lead.setCity("New York");
		lead.setCountry("USA");
		lead.setEmail("Sandhya@yahoo.com");
		lead.setPhoneNum(600505666);
		lead.setCurrentState(new Raw());
		lead.setAccount(new Account());
		lead.setSource("phone");
		lead.setZip("95121");
		lead.setProductInterest("HP PCs     ");
		lead.setInterestedCustomer("Y");
		lead.setSmsObjId(2);
		rawLeadMap.put(new Long(2), lead);
		
		lead = new Lead();
		lead.setName("Aarthi") ;
		lead.setLeadDate(new Date(2009, 4, 4));
		lead.setAddress("California");
		lead.setFax("998555151");
		lead.setCity("San Jose");
		lead.setCountry("USA");
		lead.setEmail("Aarthi@yahoo.com");
		lead.setPhoneNum(608955666);
		lead.setCurrentState(new Raw());
		lead.setAccount(new Account());
		lead.setSource("phone");
		lead.setZip("95121");
		lead.setProductInterest("HP PCs     ");
		lead.setInterestedCustomer("Y");
		lead.setSmsObjId(3);
		rawLeadMap.put(new Long(3), lead);
		
		
		lead = new Lead();
		lead.setName("Dhara") ;
		lead.setLeadDate(new Date(2009, 06, 4));
		lead.setAddress("Park Avenue");
		lead.setFax("650455151");
		lead.setCity("New York");
		lead.setCountry("USA");
		lead.setEmail("dhara@yahoo.com");
		lead.setPhoneNum(650205666);
		lead.setCurrentState(new Raw());
		lead.setAccount(new Account());
		lead.setSource("phone");
		lead.setZip("95121");
		lead.setProductInterest("Dell laptop");
		lead.setInterestedCustomer("Y");
		lead.setSmsObjId(4);
		rawLeadMap.put(new Long(4), lead);
		
		lead = new Lead();
		lead.setName("Dhara") ;
		lead.setLeadDate(new Date(2009, 07, 4));
		lead.setAddress("Park Avenue");
		lead.setFax("650455151");
		lead.setCity("New York");
		lead.setCountry("USA");
		lead.setEmail("dhara@yahoo.com");
		lead.setPhoneNum(650205666);
		lead.setCurrentState(new Raw());
		lead.setAccount(new Account());
		lead.setSource("phone");
		lead.setZip("95121");
		lead.setProductInterest("Dell laptop");
		lead.setInterestedCustomer("Y");
		lead.setSmsObjId(5);
		rawLeadMap.put(new Long(5), lead);
		
		lead = new Lead();
		lead.setName("Reshma") ;
		lead.setLeadDate(new Date(2009, 07, 28));
		lead.setAddress("Buena Vista");
		lead.setFax("32435353");
		lead.setCity("New York");
		lead.setCountry("USA");
		lead.setEmail("reshma@yahoo.com");
		lead.setPhoneNum(650205666);
		lead.setCurrentState(new Raw());
		lead.setAccount(new Account());
		lead.setSource("phone");
		lead.setZip("95121");
		lead.setProductInterest("Dell laptop");
		lead.setInterestedCustomer("Y");
		lead.setSmsObjId(6);
		rawLeadMap.put(new Long(6), lead);
	}
	
	

	public static Collection<Lead> getRawLeads(){
		Collection<Lead> leads =  rawLeadMap.values();
		Collection<Lead> rawLeads = new  ArrayList<Lead>();
		for(Lead l : leads){
			if(l.getCurrentState().getStateName().equals("Raw")){
				rawLeads.add(l);
			}
		}
		
		return rawLeads;
		
	}
	
	public static Lead getLead(long id){
		return rawLeadMap.get(new Long(id));
	}
	
	public static void updateLead(long id, Lead lead){
		rawLeadMap.remove(new Long(id));
		rawLeadMap.put(new Long(id), lead);
	}
	

}
